#include <iostream>
#include <cv.h>
/*! class for image feature points */
class IMPoint {
  public:
    int x;
    int y;
    bool loaded;
    IMPoint();
    IMPoint(int xp,int yp);
    ~IMPoint();
};

/*! class for 2D line for images */
class IMLine {
  public:
    double a;
    double b;
    double c;

    IMLine();
    IMLine(double pa, double pb, double pc);
    ~IMPoint();
};

/*! class for correspondences, its basically a mapping from one IMPoint array to another */
class PTCorrespondenceMapped {
 public:
    int index_im1;
    int index_im2;
    bool loaded;
    PTCorrespondenceMapped();
    PTCorrespondenceMapped(int index1,int index2);
    ~PTCorrespondenceMapped();
}


/*! class for correspondences, containing points rather than indices */
class PTCorrespondence {
 public:
    int x1;
    int y1;
    int x2;
    int y2;
    bool loaded;
    PTCorrespondence();
    PTCorrespondence(int px1,int py1, int px2, int py2);
    ~PTCorrespondence();
}

/*! class for correspondence lists, its a wrapper around a vector with a few useful utilities
 */
class PTCorrespondence {
 public:
    int x1;
    int y1;
    int x2;
    int y2;
    bool loaded;
    PTCorrespondence();
    PTCorrespondence(int px1,int py1, int px2, int py2);
    ~PTCorrespondence();
}


/*! class containing statistics*/
class stats {
 public:
    double mean;
    double variance;
    double average;
    double median;
    double standard_deviation;
}

/*! class for the Homography*/
class Homography {
 public:
//default is always 1 to 2, 1-> 2 so source is always 1 by default
    CvMat *H_im1_to_2, *H_im2_to_1;
    bool loaded;
    IMPoint transferPoint(IMPoint point, int sourceImage=1);
    stats findGoodnessofFit(vector<PTCorrespondence>& corrs,int errorType);
    void normalizeHomography(CvMat* H);

    void createOtherHomography(CvMat* Hfull, CvMat* HEmpty);
    void readHomographyFromFile(string fname, int sourceImage);

    Homography();
    Homography(CvMat *H,int imageH);
    ~Homography();
}


/*! class for the Fundamental Matrix*/
class Fundamental {
 public:
//default is always 1 to 2, 1-> 2 so source is always 1 by default
    CvMat *F_im1_to_2, *F_im2_to_1;
    bool loaded;
    IMLine transferPoint(IMPoint point, int sourceImage=1);
    stats findGoodnessofFit(vector<PTCorrespondence>& corrs,int errorType);
    Fundamental();

    void normalizeFundamental(CvMat* F);

    void createOtherFundamental(CvMat* Ffull, CvMat* FEmpty);
    void readFundamentalFromFile(string fname, int sourceImage);

    Fundamental();
    Fundamental(CvMat *F,int imageH);
    ~Fundamental();
}


